<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="lt" uri="http://locustree.cephb.fr" %>
<jsp:include page="/WEB-INF/jsp/xhtml-header.jsp"/><head>
<jsp:include page="/WEB-INF/jsp/header.jsp"/>
<title>Search</title>
<link href="${pageContext.request.contextPath}/static/css/json.css"  rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Search</h1>
<div style="text-align:right;"><a href="${pageContext.request.contextPath}/locustree?action=browse">Browse</a></div>
<div style="border: thin solid darkgray; margin: 10px; padding: 10px; background-color:#D0D0D0; color: black;">
<form method="POST" action="${pageContext.request.contextPath}/locustree">
<input type="hidden" name="action" value="search"/>
<fieldset>
<legend>Search</legend>
<div>
	<div style="text-align:center;">
		<label for="q">Query:</label>
		<input type="text" name="q" id="q" value="${requestScope['q']}"/>
	</div>
	
	<input type="checkbox" id="regex" name="regex" 
	 <c:choose>
	 	<c:when test="${not empty requestScope['regex']}">checked="checked"</c:when>
	 	<c:otherwise></c:otherwise>
	 </c:choose>/>
	<label for="regex">Regex</label>
	<br/>
	
	<input type="checkbox" id="casei" name="casei" 
	 <c:choose>
	 	<c:when test="${not empty requestScope['casei']}">checked="checked"</c:when>
	 	<c:otherwise></c:otherwise>
	 </c:choose>/>
	<label for="casei">Case Sensible</label>
	<br/>
	
	<input type="checkbox" id="whole" name="whole" 
	 <c:choose>
	 	<c:when test="${not empty requestScope['whole']}">checked="checked"</c:when>
	 </c:choose>/>
	 <label for="whole">Whole word</label>
	<br/>
	
	<label for="limit">Limit:</label>
	<select name="limit" id="limit">
		<option>10</option>
		<option>20</option>
		<option>50</option>
		<option>100</option>
		<option>500</option>
	</select>
	<br/>
	
	<input type="submit"/>
</div>
</fieldset>
</form>
</div>

<c:if test="${not empty timeout}">
<p>Query was aborted because it took more than ${timeout} milliseconds.</p>
</c:if>

<c:choose>
<c:when test="${empty q}">
</c:when>

<c:when test="${empty hits}">
<p>No Result</p>
</c:when>

<c:otherwise>
<table border="1">
<thead>
<tr>
	<th>Organism</th>
	<th>Track</th>
	<th>ID</th>
	<th>Name</th>
	<th>Position</th>
	<th>JSON</th>
</tr>
</thead>
<tbody>
<c:forEach var="hit" items="${hits}">
<tr>
	<td>${hit.organism.name}</td>
	<td>${hit.track.name}</td>
	<td>${hit.object.id}</td>
	<td><lt:acn>${hit.object.name}</lt:acn></td>
	<td><c:url var="url" value="locustree" >
		<c:param name="action" value="export" />
		<c:param name="organism-id" value="${hit.organism.id}" />
		<c:param name="chrom" value="${hit.chromosome.id}" />
		<c:param name="start" value="${hit.object.start}" />
		<c:param name="end" value="${hit.object.end}" />
		<c:param name="mode" value="svg" />
		</c:url><a href="${url}">${hit.chromosome.name}:${hit.object.start}-${hit.object.end}</a>
	</td>

	<td><lt:json>${hit.metadataAsJson}</lt:json></td>
</tr>
</c:forEach>
</tbody>
</table>
</c:otherwise>

</c:choose>



</body>
<jsp:include page="/WEB-INF/jsp/xhtml-footer.jsp"/>
